<!--
 * @Description: 第二十二章（transition-group过度列表） 平面过度动画酷炫
 * @Author: IA ia@kepro.space
 * @Date: 2025-02-17 23:00:58
-->
<template>
  <div>
    <h1>第二十二章（transition-group过度列表）平面过度动画酷炫</h1>
    <div class="container">
      <div>
        <h2>过度动画</h2>

        <div>
          <el-button type="primary" style="margin-bottom: 10px" @click="random">随机调换</el-button>
          <div class="wrap">
            <transition-group move-class="mmm" class="wraps" name="mmm" tag="div">
              <div class="items" v-for="item in list" :key="item.id">{{ item.number }}</div>
            </transition-group>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import 'animate.css'
import _ from 'lodash'

let list = ref(
  Array.apply(null, { length: 81 } as number[]).map((_, index) => {
    return {
      id: index,
      number: (index % 9) + 1,
    }
  }),
)

console.log('list: ', list)

const random = () => {
  list.value = _.shuffle(list.value)
}
</script>
<style scoped lang="less">
h1,
h2 {
  margin: 20px 0;
}

.container {
  display: flex;
  flex-direction: column;
}

.wraps {
  display: flex;
  flex-wrap: wrap;
  width: calc(25px * 10 + 9px);

  .mmm {
    transition: all 1s;
  }

  .items {
    width: 25px;
    height: 25px;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
